package P2POperational;

import Terminal.Terminal;

/**
 *  Created with IntelliJ IDEA.
 *  Authors: Henrique Alberto Rusa and Danilo Barbosa Porto
 *  Date: 04/11/13
 *
 *  This class creates the nodes server of the cluster.
 *  It allocates the localOperational and the ConnectionHandler for this distributed system file together with the
 *  terminal to the user input.
 */
public class Node {

    // Instances for the layer of connection and handle files
    LocalOperational operational;
    Terminal window;

    public Node(String hostName, String path){

        // Allocating memory to instances and selecting the path from current java code to start as root
        window = new Terminal();
        operational = new LocalOperational(path,hostName);

        // Linking the LocalOperational and the ConnectionHandler
        window.addListener(operational);

        // starting parameters
        new Thread(operational).start();
        window.start();
    }
}
